package com.gaozhaoyang.demo;

import com.mchange.v2.c3p0.ComboPooledDataSource;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

public class Demo01 {
    public static void main(String[] args) throws SQLException, ClassNotFoundException {
        //注册驱动
        Class.forName("com.mysql.cj.jdbc.Driver");
        //获取链接
        Connection con = DriverManager.getConnection("jdbc:mysql:///day09?serverTimezone=UTC", "root", "111111");
        //获取可执行对象
        Statement st = con.createStatement();
        //执行并回去结果
        int row = st.executeUpdate("insert into user (uid,name,sex,hobby) values(1005,'李云迪','男','弹钢琴')");
        if (row > 0) {
            System.out.println("添加成功");
        } else {
            System.out.println("添加失败");
        }
        //释放资源
        st.close();
        con.close();
    }
}
